export default {
    data() {
        return {
            loading: false,
            sort: {
                name: '',
                order: 'asc'
            },
            list: [],
            page: {
                total: 0
            }
        };
    },
    methods: {
        handleSortChange({name, order}) {
            this.list = this.list.sort((a, b) => {
                if (a[name] === undefined || b[name] === undefined) return 0;
                let aValue = a[name].toString();
                let bValue = b[name].toString();
                if (order === 'asc') {
                    return aValue.localeCompare(bValue);
                }
                return bValue.localeCompare(aValue);
            });
        }
    }
};
